//
//  XJUserInfoManager.m
//  EPA
//
//  Created by lanou3g on 16/4/27.
//  Copyright © 2016年 ZhangXJ. All rights reserved.
//

#import "XJUserInfoManager.h"

@implementation XJUserInfoManager

+ (instancetype)shareManager {
    static XJUserInfoManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[XJUserInfoManager alloc] init];
    });
    return manager;
}


- (void)loginWithDict:(NSDictionary *)dict {
    if (dict) {
        [self setValuesForKeysWithDictionary:dict];
    }
}

- (void)saveUserInfo {
    [[NSUserDefaults standardUserDefaults] setObject:self.uid forKey:@"uid"];
    [[NSUserDefaults standardUserDefaults] setObject:self.auth forKey:@"auth"];
    [[NSUserDefaults standardUserDefaults] setObject:self.uname forKey:@"uname"];
    [[NSUserDefaults standardUserDefaults] setBool:self.loginStatus forKey:@"loginStatus"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)loadFromSandBox {
    NSUserDefaults *defults = [NSUserDefaults standardUserDefaults];
    self.uname = [defults objectForKey:@"uname"];
    self.auth = [defults objectForKey:@"auth"];
    self.loginStatus = [defults boolForKey:@"loginStatus"];
    self.uid = [defults stringForKey:@"uid"];
}
@end
